<?php
/**
 * Nordic Repository
 * 
 * LICENSE
 * 
 * The new BSD license is applied on this source-file. For further
 * information please visit http://license.nordic-dev.de/newbsd.txt
 * or send an email to andre.moelle@gmail.com.
 */

/**
 * Necessary includes.
 */
Zend_Loader::loadCLass('Zend_View_Abstract');

/**
 * This class adds some functionalities to "Zend_View_Abstract".
 * 
 * @category   Nordic
 * @package    Nordic_View
 * @copyright  2007 Nordic Development
 * @license    http://license.nordic-dev.de/newbsd.txt (New-BSD license)
 * @author     Andre Moelle <andre.moelle@gmail.com>
 * @version    $Id: View.php 3 2007-07-08 09:21:42Z andre.moelle $
 */
class Nordic_View extends Zend_View_Abstract
{
	/**
	 * Runs the view.
	 * 
	 * You can assign as many templates as you want. They are executed
	 * in the order as they are assigned. If one of these files does
	 * not exist in the script-path a "Zend_View_Exception" will be
	 * thrown.
	 * 
	 * @throws Zend_View_Exception
	 * @param mixed
	 * @return void
	 */
	protected function _run ()
	{
		foreach(func_get_args() as $name)
		{
			include($this->_script(basename($name)));
		}
	}
	
	/**
	 * Returns true if the template exists in the script-path.
	 * 
	 * @param string $name name of the template
	 * @return boolean
	 */
	public function existsTemplate ($name)
	{
		foreach($this->getScriptPaths() as $path)
		{
			if(file_exists($path . $name))
			{
				return true;
			}
		}
		
		return false;
	}
}
?>